import HttpKit from '../../utils/http-kit'

export default {
  /**
   * @description 获取广告位列表
   * @returns {Promise<T | never>}
   */
  getSpotList () {
    return HttpKit.get('/spots', {pageNumber: '0', pageSize: '10000'}).then(
      res => res.data
    )
  },
  /**
   * @description 添加广告位
   * @param spot 要添加的广告位对象
   * @returns {Promise<T | never>}
   */
  addSpot (spot) {
    return HttpKit.post('/spot/add', {
      'communityId': spot.communityId,
      'communityName': 'community',
      'id': 0,
      'imageSrc': spot.image,
      'isBusy': false,
      'isRepair': false,
      'spotSize': spot.size,
      'spotType': spot.type
    }).then(
      res => res.data
    )
  },
  /**
   * @description 删除广告位
   * @param spotId 要删除的广告位编号
   * @returns {Promise<T | never>}
   */
  deleteSpot (spotId) {
    return HttpKit.delete('/spot/delete/' + spotId, {}).then(
      res => res
    )
  },
  /**
   * @description 获取广告位的档期
   * @param spotId 广告位编号
   * @returns {Promise<T | never>}
   */
  getDate (spotId) {
    return HttpKit.get('/spotSchedule/' + spotId, {pageNumber: '0', pageSize: '10000'}
    ).then(
      res => res.data
    )
  },
  /**
   * @description 获取最新的广告位id
   * @param spotId
   * @returns {Promise<T | never>}
   */
  getlatestReserveDate (spotId) {
    return HttpKit.get('/spot/latestReserveDate/' + spotId, {}
    ).then(
      res => res
    )
  },
  /***
   * @description 用户预定广告位
   * @param bookVo
   * @returns {*|Promise<AxiosResponse<T>>}
   */
  bookSpot: function (bookVo) {
    return HttpKit.post('/book/bookSpot', {
      'contractId': 0,
      'customerId': bookVo.customerId,
      'endDate': bookVo.endDate,
      'id': 0,
      'sellId': 0,
      'spotId': bookVo.spotId,
      'startDate': bookVo.startDate,
      'status': 'string',
      'workOrderId': 0
    })
  },
  /**
   * @description 用户保障
   * @param maintenanceVo
   * @returns {Promise<T | never>}
   */
  reportError (maintenanceVo) {
    return HttpKit.post('/maintenance/apply', {
      customerId: maintenanceVo.customerId,
      id: '',
      sellId: '',
      spotId: maintenanceVo.spotId,
      status: '',
      workerOrderId: ''
    }
    ).then(
      res => res.data
    )
  }
}
